var path = require('path');

function SocketProcess(action){
	this.action = null;
	var _paths = action.split('.');
	var actionPath = '';
	for(var i=0; i<_paths.length-1;i++){
		actionPath = path.join(actionPath, 'app', _paths[i]);
	}
	if(actionPath){
		var conteoller = require(path.join(process.cwd(), actionPath));
		this.action = conteoller[_paths[_paths.length-1]];
	}
	this.session = {};
	this.data = {};
	this.params = {};
	this.appContext = {};
}

SocketProcess.prototype.getAction = function(){return this.action;};
SocketProcess.prototype.setSession = function(session){this.session = session;};
SocketProcess.prototype.setData = function(data){this.data = data;};
SocketProcess.prototype.addData = function(key, value){this.data[key] = value;};
SocketProcess.prototype.setParams = function(params){
	for(var n in params){
		this.params[n] = params[n];
	}
};
SocketProcess.prototype.setContext = function(context){this.appContext = context;};

exports.SocketProcess = SocketProcess;